/**
 * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.glc.hms.core.common.log;

import com.glc.hms.common.constant.LogEnum;
import com.glc.hms.system.entity.SysLog;

import java.util.Date;

/**
 * 日志对象创建工厂
 * @author Santa
 * @since 2019/11/14
 */
public class LogFactory {

    /**
     * 创建操作日志
     */
    public static SysLog createOperationLog(String userName, String operationName, String param, String methodName, Long time,String ip) {
        SysLog operationLog = new SysLog();
        operationLog.setMethod(methodName);
        operationLog.setIp(ip);
        operationLog.setOperation(operationName);
        operationLog.setParams(param);
        operationLog.setType(LogEnum.BUSINESSLOG.getItemFlag());
        operationLog.setTime(time);
        operationLog.setUsername(userName);
        operationLog.setCreateDate(new Date());
        return operationLog;
    }

    /**
     * 创建登录日志
     */
    public static SysLog createLoginLog(String userName, String operationName, String param, String methodName, Long time,String ip) {
        SysLog loginLog = new SysLog();
        loginLog.setMethod(methodName);
        loginLog.setIp(ip);
        loginLog.setOperation(operationName);
        loginLog.setParams(param);
        loginLog.setType(LogEnum.LOGINLOG.getItemFlag());
        loginLog.setTime(time);
        loginLog.setUsername(userName);
        loginLog.setCreateDate(new Date());
        return loginLog;
    }

}
